#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <functional>
#include <queue>
#include <stdio.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#ifndef TEST
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#endif
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> piii;

// fast input
inline ll read() {
    ll X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch))
        X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}

// fast output
inline void write(ll x) {
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}

#define pb push_back
#define mp make_pair

void solve() {
    vector<int> ans(9);
    string st = "AHCPC2023";
    int n = read();
    string s;
    cin >> s;
    const int MOD = 1000000007;
    for (int i = 0; i < n; i++) {
        for (int j = 8; j > 0; j--) {
            if (s[i] == st[j]) {
                ans[j] += ans[j - 1];
                ans[j] %= MOD;
            }
        }
        if (s[i] == st[0]) {
            ans[0] += 1;
            ans[0] %= MOD;
        }
    }
    write(ans[8]);
    putchar('\n');
}

int32_t main() {
    int t = 1;
    while (t--) {
        solve();
    }
}